<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 普通函数
        let fun1 = function () {
            console.log('fun1')
        }
        // 箭头函数,相当于java中的lambda表达式。
        let fun2 = () => {
            console.log('fun2')
        }
        // 箭头函数的this指向
        // 1.箭头函数没有自己的this，它的this是继承外层的this(这里是window对象)，
        let person = {
            name: 'zhangsan',
            age: 18,
            showName: function () {
                console.log(this.name)
            },
            viewName: () => {
                console.log(this.name)
            } 
        }
        person.showName() // zhangsan
        person.viewName() // undefined
    </script>
</head>
<body>
    
</body>
</html>